{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 35
    },
    "colab_type": "code",
    "id": "8J3ANnymelvo",
    "outputId": "fcff1d43-1bb1-4879-8a4a-d3f7f72f29a8"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 8, 27, 64, 125]\n"
     ]
    }
   ],
   "source": [
    "# This is a familiar Python for..in loop for iterating over an array\n",
    "cubes = []\n",
    "for x in [1,2,3,4,5]:\n",
    "    cubes.append(x**3)\n",
    "print(cubes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 35
    },
    "colab_type": "code",
    "id": "ctsPWMvYenax",
    "outputId": "ac8bce3b-7d2f-4a6b-ac91-5f0f37213869"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 8, 27, 64, 125]\n"
     ]
    }
   ],
   "source": [
    "# The list comprehension achieves the same thing\n",
    "cubes = [x**3 for x in [1,2,3,4,5]]\n",
    "print(cubes)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 35
    },
    "colab_type": "code",
    "id": "LMGZKyRwer2P",
    "outputId": "6e9f4608-cafe-499e-b9ea-08f4c552f175"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 8, 27, 64, 125]\n"
     ]
    }
   ],
   "source": [
    "cubes = [x**3 for x in range(1,6)]\n",
    "print(cubes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 35
    },
    "colab_type": "code",
    "id": "SPX5WXHee6F1",
    "outputId": "d75e5dbd-60c9-4ca8-c052-0e6bb3f10213"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['TERRY GILLIAM', 'TERRY JONES']\n"
     ]
    }
   ],
   "source": [
    "names = [\"Graham Chapman\", \"John Cleese\", \"Terry Gilliam\", \"Eric Idle\", \"Terry Jones\"]\n",
    "print([name.upper() for name in names if name.startswith(\"T\")])\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "colab": {
   "name": "Exercise01.ipynb",
   "provenance": [],
   "version": "0.3.2"
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
